@echo off 
:: 设置控制台编码为UTF-8，解决中文乱码 
chcp 65001 >nul 

echo 开始启动所有组件... 
echo 注意：请不要关闭自动打开的命令窗口，关闭窗口将停止对应服务 

:: 启动 Elasticsearch 
echo 启动 Elasticsearch... 
start "Elasticsearch" cmd /k "chcp 65001 >nul && cd /d C:\Users\22071\Desktop\zenith\path\elasticsearch-9.1.3\bin && elasticsearch.bat" 

:: 等待Elasticsearch初始化 
echo 等待Elasticsearch初始化... 
timeout /t 20 /nobreak >nul 

:: 启动 Logstash 
echo 启动 Logstash... 
taskkill /f /im java.exe /fi "WINDOWTITLE eq Logstash" 2>nul 
start "Logstash" cmd /k "chcp 65001 >nul && cd /d C:\Users\22071\Desktop\zenith\path\logstash-9.1.3\bin && logstash.bat -f C:\Users\22071\Desktop\zenith\path\logstash-9.1.3\config\logstash-simple.conf" 

:: 等待Logstash初始化 
echo 等待Logstash初始化... 
timeout /t 10 /nobreak >nul 

:: 启动 Kibana 
echo 启动 Kibana... 
start "Kibana" cmd /k "chcp 65001 >nul && cd /d C:\Users\22071\Desktop\zenith\path\kibana-9.1.3\bin && kibana.bat" 

:: 启动 APM Server 
echo 启动 APM Server... 
start "APM Server" cmd /k "chcp 65001 >nul && cd /d C:\Users\22071\Desktop\zenith\path\apm-server-9.1.3-windows-x86_64 && apm-server.exe" 

:: 启动 Nacos 
echo 启动 Nacos... 
start "Nacos" cmd /k "chcp 65001 >nul && cd /d C:\Users\22071\Desktop\zenith\path\nacos\bin && startup.cmd -m standalone" 

:: 等待Nacos初始化 
echo 等待Nacos初始化... 
timeout /t 15 /nobreak >nul 

:: 启动 Redis 
echo 启动 Redis... 
start "Redis" cmd /k "chcp 65001 >nul && cd /d C:\Users\22071\Desktop\zenith\path\Redis && redis-server.exe redis.windows.conf" 

:: 启动 Sentinel Dashboard 
echo 启动 Sentinel Dashboard... 
start "Sentinel Dashboard" cmd /k "chcp 65001 >nul && java -jar ""C:\Users\22071\Desktop\zenith\path\sentinel-dashboard-1.8.8.jar""" 

:: 启动 Qdrant 
echo 启动 Qdrant... 
start "Qdrant" cmd /k "chcp 65001 >nul && cd /d C:\Users\22071\Desktop\zenith\path\qdrant-x86_64-pc-windows-msvc && qdrant.exe" 

:: 启动 Prometheus 
echo 启动 Prometheus... 
start "Prometheus" cmd /k "chcp 65001 >nul && cd /d C:\Users\22071\Desktop\zenith\path\prometheus-3.6.0-rc.0.windows-amd64 && prometheus.exe" 

:: 等待基础设施服务完全启动 
echo 等待所有基础设施服务初始化... 
timeout /t 30 /nobreak >nul 

:: 启动微服务 - 开始构建并启动 
echo 开始启动微服务... 

:: 启动 zenith-gateway 
echo 启动 API网关服务... 
start "Zenith Gateway" cmd /k "chcp 65001 >nul && cd /d C:\Users\22071\Desktop\zenith\zenith-mind\zenith-gateway && mvn spring-boot:run" 

timeout /t 10 /nobreak >nul 

:: 启动 zenith-user-service 
echo 启动 用户服务... 
start "Zenith User Service" cmd /k "chcp 65001 >nul && cd /d C:\Users\22071\Desktop\zenith\zenith-mind\zenith-user-service && mvn spring-boot:run" 

timeout /t 10 /nobreak >nul 

:: 启动 zenith-api-service 
echo 启动 API服务... 
start "Zenith API Service" cmd /k "chcp 65001 >nul && cd /d C:\Users\22071\Desktop\zenith\zenith-mind\zenith-api-service && mvn spring-boot:run" 

timeout /t 10 /nobreak >nul 

:: 启动 zenith-edu-service 
echo 启动 教育服务... 
start "Zenith Edu Service" cmd /k "chcp 65001 >nul && cd /d C:\Users\22071\Desktop\zenith\zenith-mind\zenith-edu-service && mvn spring-boot:run" 

timeout /t 10 /nobreak >nul 

:: 启动 zenith-article-service 
echo 启动 文章服务... 
start "Zenith Article Service" cmd /k "chcp 65001 >nul && cd /d C:\Users\22071\Desktop\zenith\zenith-mind\zenith-article-service && mvn spring-boot:run" 

timeout /t 10 /nobreak >nul 

:: 启动 zenith-middleware-service 
echo 启动 中间件服务... 
start "Zenith Middleware Service" cmd /k "chcp 65001 >nul && cd /d C:\Users\22071\Desktop\zenith\zenith-mind\zenith-middleware-service && mvn spring-boot:run" 

echo 所有组件启动命令已执行完成 
echo 部分组件需要一定时间初始化，请耐心等待 
echo 服务访问地址： 
echo - API网关: http://localhost:9000 
echo - Nacos控制台: http://localhost:8848/nacos 
echo - Kibana: http://localhost:5601 
echo - Grafana: http://localhost:3000 
echo 按任意键退出本窗口... 
pause >nul